package com.obradovicnjegovan.webprodavnica.entities;

import java.io.Serializable;
import java.util.UUID;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Version;

import org.apache.tapestry5.beaneditor.NonVisual;

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class OpstiDomenskiObjekat implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3847184265316505189L;
	@NonVisual
	private Long _id;
	@NonVisual
    private String _uuid = UUID.randomUUID().toString();
    @Version
    @Column(name = "ODO_VERSION")
    @NonVisual
    private int _version;
	public OpstiDomenskiObjekat() {
		super();
		// TODO Auto-generated constructor stub
	}
	@Id
    @GeneratedValue(strategy=GenerationType.AUTO)
	public Long get_id() {
		return _id;
	}
	public void set_id(Long _id) {
		this._id = _id;
	}
	@Basic
	public String get_uuid() {
		return _uuid;
	}
	public void set_uuid(String _uuid) {
		this._uuid = _uuid;
	}
	public int get_version() {
		return _version;
	}
	public void set_version(int _version) {
		this._version = _version;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
        if (o == null || !(o instanceof OpstiDomenskiObjekat)) {
            return false;
        }
        OpstiDomenskiObjekat other = (OpstiDomenskiObjekat)o;
        if (get_id() != null) {
                return get_id().equals(other.get_id());
        }
        if (get_uuid() == null) return false;
        return get_uuid().equals(other.get_uuid());
	}
	
	@Override
	public int hashCode() {
        if (get_uuid() != null) {
            return get_uuid().hashCode();
        } else {
            return super.hashCode();
        }
	}

}
